package com.sooncode.project.focusservice.controller;

import com.sooncode.project.focusservice.model.CourseSubjects;
import com.sooncode.project.focusservice.service.CourseSubjectsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("courseSubject")
public class CourseSubjectsController {
    @Autowired
    private CourseSubjectsService service;

    @PostMapping("courseSubject")
    public boolean add(@RequestParam Map map){
        return service.add(map);
    }

    @PutMapping("courseSubject")
    public boolean modify(@RequestParam String id,@RequestParam Map map){
        map.remove("id");
        return service.modify(id,map);
    }

    @DeleteMapping("courseSubject")
    public boolean delete(@RequestParam String[] ids){
        for(String id:ids){
            service.delete(id);
        }
        return true;
    }
    @GetMapping("courseSubjects")
    public List<CourseSubjects> getList(){
        return service.getList();
    }

}
